package day06_task;

import cn.robin.event.task1;
import cn.robin.event.task2;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = {task2.class})
public class test2 {
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
    @Test
    public void method1(){
        System.out.println("发布事件");
        applicationEventPublisher.publishEvent(new task1("dgut"));
        System.out.println("结束发布事件");
    }
}
